package com.atguigu.gmall.gateway.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Component
//@Order(1) // 通过order注解指定执行顺序，数值越小，优先级越高
public class MyGlobalFilter implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("全局过滤器，拦截所有经过网关的请求。。。。。。。。。。。。。。");
        // 放行
        return chain.filter(exchange);
    }

    // 返回值越小，优先级越高
    @Override
    public int getOrder() {
        return 1;
    }
}
